#include <bits/stdc++.h>
using namespace std;
#define N 100005
typedef long long ll;
ll n, m, K, T;
ll A[N], a[N], c[N], X[10], b[N];
ll ans[N];
ll F[55];
string s[55];
ll qpow(ll a, ll b)
{
    ll ans = 1;
    for (; b; b >>= 1, a *= a)
        b & 1 ? ans *= a : 0;
    return ans;
}
void solve()
{
    for (int i = 0; i < 4; i++)
        scanf("%lld", X + i);
    for (int i = 1; i <= n; i++)
        a[i] = A[i] ^ X[i % 4];
    ll k;
    for (int t = 1; t <= m; t++)
    {
        k = log(c[t]) / log(2);
        if (qpow(2, k) < n)
            k++;
        if (c[t] == 1)
        {
            ans[t] = 1;
            continue;
        }
        for (int i = k - 1; i >= 0; i--)
        {
            for (int j = 0; j < F[k] / 2 && j * 2 <= c[t]; j++)
            {
                int drg = s[i][j] - '0';
                if (!drg)
                {
                    if (a[j << 1] >= i)
                        b[j] = a[j << 1];
                    else
                        b[j] = a[j << 1 | 1];
                }
                else
                {
                    if (a[j << 1 | 1] >= i)
                        b[j] = a[j << 1 | 1];
                    else
                        b[j] = a[j << 1];
                }
            }
        }
    }
}
int main()
{
    freopen("arena.in", "r", stdin);
    freopen("arena.out","w",stdout);
    scanf("%lld%lld", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%lld", A + i);
    for (int i = 1; i <= m; i++)
        scanf("%lld", c + i);
    K = log(n) / log(2);
    if (qpow(2, K) < n)
        K++;
    F[0] = 1;
    for (int i = 1; i <= K; i++)
        F[i] = F[i - 1] << 1;
    for (int i = 1; i <= K; i++)
        cin >> s[i];
    scanf("%lld", &T);
    cout << 5;
    return 0;
}
